package com.macro.mall.common.utils;

import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.HashUtil;
import cn.hutool.core.util.IdUtil;

/**
 * @author wwj
 */

public class IdUtils {

    static {

        Snowflake.DEFAULT_TWEPOCH = 1664176054958L;
    }


    private static Snowflake snowflake = IdUtil.getSnowflake();


    /**
     * 生成long 类型的ID
     *
     * @return
     */
    public static Long getId() {

        return snowflake.nextId();
    }

    public static long generateDateTime(long id) {
        return snowflake.getGenerateDateTime(id);
    }

    /**
     * 生成String 类型的ID
     *
     * @return
     */
    public static String getIdStr() {
        return snowflake.nextIdStr();
    }

    public static void main(String[] args) {

        for (int i = 0; i < 100; i++) {
            long generateDateTime = snowflake.getGenerateDateTime(getId());

        }
    }

}
